package controller;

import gui.Gui;

import java.io.File;

import javax.swing.JFrame;

import model.Project;
import model.Scan;
	
	
public class Controller {
	private Gui gui;
	private Project project;
	final private FileIO fileIO = new FileIO();
	final private Parser parser = new Parser(this);
	
	Controller(){
		project = new Project();
	}
	public boolean selectFile(JFrame frame) {
		return fileIO.selectInputFile(frame);
	}
	public String getSelectedFileOrDirectoryFullPath (){
		return fileIO.getSelectedFileOrDirectoryFullPath();
	}
	public void setGui(Gui gui){
		this.gui = gui;
	}
	public void analyzeFiles(String[] stringFiles, JFrame frame) {
		File[] files = fileIO.parseForFilesAndDirectories(stringFiles);
		if (files.length>0){
			project.setFiles(files);
			parser.parseFiles(files, frame);
		}
		
		gui.displayAllHosts(project.getTree());
		project.checkForInterestingPorts();
	}
	public Scan addHost(String iPAddress, String command) {
		return project.addHost(iPAddress, command);
		
	}
	public void printHostsPorts() {
		project.printHostPorts();
		
	}

	
}

